import unittest

from simpy import Environment

from models import Goods, PickCar, TransportCar, Instruction
from typings import Pos3


class ModelTestCase(unittest.TestCase):
    """
    Model 相关测试
    """

    def test_goods(self):
        goods = Goods("物品1", "g00001", "货柜1", (0, 0, 0))
        self.assertIsNotNone(goods)
        print(goods)

    def test_pick_car(self):
        env = Environment()
        pos: Pos3 = (1, 2, 0)
        ins = Instruction('INS-000001', pos)
        pick_car = PickCar(env, "货柜1-取用车")
        self.assertIsNotNone(pick_car)
        print(pick_car)

        def process():
            print(f'[{env.now}]')
            with pick_car.request() as req:
                yield req
                print(f'[{env.now}]')
                yield env.process(pick_car.move_to(ins))
                print(f'[{env.now}]')

        env.process(process())
        env.run()

    def test_transport_car(self):
        env = Environment()
        transport_car = TransportCar(env, "货柜1-运输车", 0)
        self.assertIsNotNone(transport_car)
        print(transport_car)


if __name__ == '__main__':
    unittest.main()
